
.PHONY: check report clean check-headers

TESTRESULTS := $(patsubst %.test, %.testresults, $(wildcard test/*.test))
HEADERS = $(wildcard *.hpp)
PRECOMPILED-HEADERS = $(HEADERS:%.hpp=%.hpp.gch)


%.testresults: %.test
	@ expect $< > $@ 2>&1 || (echo; echo ">>TEST FAILED<<") >> $@

check: $(TESTRESULTS)
	@ grep ">>TEST FAILED<<" $(TESTRESULTS) | wc | grep "0       0       0" > /dev/null

report: $(TESTRESULTS)
	@ grep ">>TEST FAILED<<" $(TESTRESULTS)

clean:
	rm -f $(TESTRESULTS)
	rm -f $(PRECOMPILED-HEADERS)

%.hpp.gch: %.hpp
	g++ -c -x c++-header -o /dev/null $< || true

check-headers: $(PRECOMPILED-HEADERS)

